Pure Type Systems in Rewriting Logic: Specifying Typed Higher-Order Languages in a First-Order Logical Framework
نویسندگان
چکیده
The logical and operational aspects of rewriting logic as a logical framework are tested and illustrated in detail by representing pure type systems as object logics. More precisely, we apply membership equational logic, the equational sublogic of rewriting logic, to specify pure type systems as they can be found in the literature and also a new variant of pure type systems with explicit names that solves the problems with closure under α-conversion in a very satisfactory way. Furthermore, we use rewriting logic itself to give a formal operational description of type checking, that directly serves as an efficient type checking algorithm. The work reported here is part of a more ambitious project concerned with the development of the open calculus of constructions, an equational extension of the calculus of constructions that incorporates rewriting logic as a computational sublanguage. This paper is a detailed study on the ease and naturalness with which a family of higher-order formal systems, namely pure type systems (PTSs) [6,50], can be represented in the first-order logical framework of rewriting logic [36]. PTSs generalize the λ-cube [1], which already contains important calculi like λ→ [12], the systems F [23,43] and Fω [23], a system λP close to the logical framework LF [24], and their combination, the calculus of constructions CC [16]. PTSs are considered to be of key importance, since their generality and simplicity makes them an ideal basis for representing higher-order logics, either via the propositions-as-types interpretation [21], or via their use as a higher-order logical framework in the spirit of LF [24,20] or Isabelle [39]. Currently visiting University of Illinois at Urbana-Champaign, Computer Science Department Urbana, IL 61801, USA, e-mail: [email protected] O. Owe et al. (Eds.): From OO to FM (Dahl Festschrift), LNCS 2635, pp. 334–375, 2004. c © Springer-Verlag Berlin Heidelberg 2004 Pure Type Systems in Rewriting Logic 335 Exploiting the fact that rewriting logic (RWL) and its membership equational sublogic (MEL) [10] have initial and free models, we can define the representation of PTSs as a parameterized theory in the framework logic; that is, we define in a single parametric way all the representations for the infinite family of PTSs. Furthermore, the representational versatility of RWL, and of MEL, are also exercised by considering four different representations of PTSs at different levels of abstraction, from a more abstract textbook version in which terms are identified up to α-conversion, to a more concrete version with a calculus of names and explicit substitutions, and with a type checking inference system that can in fact be used as a reasonably efficient implementation of PTSs by executing the representation in the Maude language [13,14]. This case study complements earlier work [31,32], showing that rewriting logic has good properties as a logical framework to represent a wide range of logics, including linear logic, Horn logic with equality, first-order logic, modal logics, sequent-based presentations of logics, and so on. In particular, representations for the λ-calculus, and for binders and quantifiers have already been studied in [32], but this is the first systematic study on the representation of typed higher-order systems. One property shared by all the above representations, including all those discussed in this paper, is that what might be called the representational distance between the logic being formalized and its rewriting logic representation is virtually zero. That is, both the syntax and the inference system of the object logic are directly and faithfully mirrored by the representation. This is an important advantage both in terms of understandability of the representations, and in making the use of encoding and decoding functions unnecessary in a so-called adequacy proof. Besides the directness and naturalness with which logics can be represented in a framework logic, another important quality of a logical framework is the scope of its applicability; that is, the class of logics for which faithful representations preserving relevant structure can be defined. Typically, we want representations that both preserve and reflect provability; that is, something is a theorem in the original logic if and only if its translation can be proved in the framework’s representation of the logic. Such mappings go under different names and differ in their generality; in higher-order logical frameworks representations are typically required to be adequate mappings [20], and in the theory of general logics more liberal, namely conservative mappings of entailment systems [35], are studied. In this paper, we we further generalize conservative mappings to the notion of a sound and complete full correspondence of sentences between two entailment systems. In fact, all the representations of PTSs that we consider are correspondences of this kind. Sound and complete full correspondences are systematically used not only to state the correctness of the representations of PTSs at different levels of abstraction, but also to relate those different levels of abstraction, showing that the more concrete representations correctly implement their more abstract counterparts. A systematic way of comparing the scopes of two logical frameworks F and G is to exhibit a sound and complete full correspondence F G, representing 336 Mark-Oliver Stehr and José Meseguer F in G. In view of this quite general concept, it is important to add that the representational distance, which we informally define as the complexity of this correspondence, is an important measure of the quality of the representation. Since such correspondences form a category, and therefore compose, this then shows that the scope of G is at least as general as that of F . Since PTSs include the system λP, close to the logical framework LF, and the calculus of constructions CC, the results in this paper indicate that the scope of rewriting logic is at least as general as that of those logics. Furthermore, since there are no adequate mappings from linear logic to LF in the sense of [20], but there is a conservative mapping of logics from linear logic to rewriting logic [32], this seems to indicate that the LF methodology together with its rather restrictive notion of adequate mapping is more specialized than the rewriting logic approach. In this paper we will be concerned with PTSs as formal systems represented inside informal set theory, or inside another formal system such as rewriting logic or its membership equational sublogic. For formal systems in general, and for PTSs in particular, there is not a single canonical presentation. Instead each presentation is tailored for specific purposes. For example, there are different formulations of PTSs with different sets of rules, but the same sets, or related sets, of derivable sentences. Furthermore, presentations can be more or less abstract, e.g. concerning the treatment of names, or concerning the degree of operationality. It is needless to say that the use of some general terminology is highly desirable in this situation to deal with these issues in a systematic way. To this end, we follow the general logics methodology [35] to use an abstract logical metatheory, which is concerned with formal systems and their relationships, together with a particular formal system as a logical framework, namely rewriting logic. Regarding general logics terminology, we furthermore found that the notion of correspondences between sentences that generalizes the idea of maps of entailment systems is a simple a useful tool to structure our results. In summary, we think that, besides the more technical contributions to PTSs discussed in Section 5, the key contributions of this paper are threefold. First, as already mentioned, the expressiveness of RWL and its MEL sublogic as logical frameworks is tested and demonstrated by showing how a well-known family of typed higher-order logics, that are themselves frequently used for logical framework purposes, are naturally represented. But this brings along with it a second important consequence: our representation maps suggest fruitful generalizations of PTSs, in which higher-order reasoning is seamlessly integrated with equational and rewriting logic reasoning. The need for such multiparadigm integrations of equational logic and type theory is clearly recognized by many researchers, because of the restrictive notions of equality and computation in traditional λ-calculi. Specifically, as further explained in Section 5.1, an integration of a typed higher-order λ-calculus with MEL and RWL, namely the open calculus of constructions (OCC) [48], has been developed by the first author as a natural extension and generalization of the ideas presented here. It is worth pointing out that the executability of the representation maps has made possible the development of a prototype for OCC in Maude which has been used in a wide range Pure Type Systems in Rewriting Logic 337 of examples concerned with programming, specification and interactive theorem proving [48]. A third and final consideration is that our representation maps have another important advantage: since MEL and RWL theories have initial models, theories with initial semantics can be endowed with inductive reasoning principles. It is indeed such an initial (or free extension) semantics that is used in all our representations of PTSs. This means that we can not only simulate PTSs in MEL or RWL using our representations, but we can also reason about the metalogical properties of such systems using induction. Different approaches to metalogical reasoning are touched upon in Section 5.2. These include the use of a higher-order logic such as OCC as a metalogic to reason about formalisms represented in its MEL or RWL sublogic, and the use of a reflective metalogical framework such as RWL, which is discussed at greater length in [4].
منابع مشابه
R O M a Elfrw: a Tool for Higher-order Dependently Typed Rewriting (system Description)
We report on an extension of the SML implementation of the logic programming language Elf Pfe to support the check of convergence for higher order critical pairs Since Elf is based on the Edinburgh Logical Framework HHP it utilizes dependent types Therefore in the implementation a generalization of the critical pair lemma to this case as done in Vir had to be employed
متن کاملSpecifying Theorem Provers in a Higher-Order Logic Programming Language
Since logic programming systems directly implement search and unification and since these operations are essential for the implementation of most theorem provers, logic programming languages should make ideal implementation languages for theorem provers. We shall argue that this is indeed the case if the logic programming language is extended in several ways. We present an extended logic progra...
متن کاملElf: A Meta-Language for Deductive Systems (System Descrition)
1 Overview Elf is a uniform metalanguage for the formalization of the theory of programming languages and logics. It provides means for 1. specifying the abstract syntax and semantics of an object language in a natural and direct way; 2. implementing related algorithms (e.g., for type inference, evaluation, or proof search); and 3. representing proofs of meta-theorems about an object language, ...
متن کاملNatural Inductive Theorems for Higher-Order Rewriting
The notion of inductive theorems is well-established in first-order term rewriting. In higherorder term rewriting, in contrast, it is not straightforward to extend this notion because of extensionality (Meinke, 1992). When extending the term rewriting based program transformation of Chiba et al. (2005) to higher-order term rewriting, we need extensibility, a property stating that inductive theo...
متن کاملBeluga: A Framework for Programming and Reasoning with Deductive Systems
Beluga is an environment for programming and reasoning about formal systems given by axioms and inference rules. It implements the logical framework LF for specifying and prototyping formal systems via higher-order abstract syntax. It also supports reasoning: the user implements inductive proofs about formal systems as dependently typed recursive functions. A distinctive feature of Beluga is th...
متن کامل